import request from '@/utils/request'

// 注册接口函数
export const userRegisterService = (registerData) => {
    const params = new URLSearchParams()
    for (const key in registerData) {
        params.append(key, registerData[key])
    }
    return request.post('/user/register', params)
}



// 登录接口函数
export const userLoginService = (registerData) => {
    const params = new URLSearchParams()
    for (const key in registerData) {
        params.append(key, registerData[key])
    }
    return request.post('/user/login', params)
}



//获取个人信息
export const getUserInfoService = () => {
    return request.get('/user/userInfo');
}


//修改个人信息
export const getUserInfoUpdateService = (userInfo) => {
    return request.put('/user/update', userInfo)
}


// 修改个人头像
export const getUserInfoAvatarService = (avatar) => {
    const params = new URLSearchParams();
    params.append('avatarUrl', avatar)
    return request.patch('/user/updateAvatar', params)
}


// 重制密码
export const getUserInfoResetPasswordService = (resetPassword) => {
    return request.patch('/user/updatePwd', resetPassword)
}